let nums = 0
const workerList = []
self.addEventListener('connect', e => {
  console.log('========');
  
  const port = e.ports[0]
  port.addEventListener('message', e => {
    nums += e.data === 'add' ? 1 : -1
    workerList.forEach(port => {
      port.postMessage(nums)
    }) 
  })
  port.start()
  workerList.push(port)
  port.postMessage(nums)
})